﻿function Circle(position, radius) {
    Node.apply(this, [document.createElementNS('http://www.w3.org/2000/svg', "circle"), position, { w: radius, h: radius }]);

    this.onUpdateLayout = function () {
        this._domEl.setAttribute("cx", this._position.x);
        this._domEl.setAttribute("cy", this._position.y);
        this._domEl.setAttribute("r", this._size.w);
        if (this.logFlag) {
            worker.postMessage("Create a Circle:  x:" + this._position.x + ", radius:" + radius);
        }
        this.logFlag = false;
    };
    this.getLinkPos = function () {
        return [];
    }
    this.hitTest = function (pos) {
        if (pos.x > this.getPosition().x
            && pos.y > this.getPosition().y
            && pos.x < this.getPosition().x + this.getSize().w
            && pos.y < this.getPosition().y + this.getSize().h) {
            return true;
        }
        return false;
    }

    this._position = this.getPosition();
    this._size = this.getSize();

    this.getCenterPos = function () {
        var x = this._position.x + this._size.w;
        var y = this._position.y + this._size.w;
        return { x: x, y: y };
    }
}